package AccountWindow.HotelAdmin;

import AccountWindow.HotelAdmin.AccountDetailWindow.AccountDetailWindow;
import AccountWindow.HotelAdmin.PersonalDetailWindow;
import AccountWindow.HotelAdmin.RoomDetailWindow.RoomDetailWindow;

import javax.swing.*;
import java.awt.*;

public class HotelAdminWindow extends JFrame {

    public static String nowAccountID;
    public JPanel hotelAdminPanel;
    public CardLayout cardLayout = new CardLayout();
    private JMenuBar menuBar = new JMenuBar();
    //客房信息、用户信息、新增批准、个人信息
    private JButton roomDetail = new JButton("客房信息");
    private JButton accountDetail = new JButton("用户信息");
    private JButton personalDetail = new JButton("个人信息");

    public RoomDetailWindow roomDetailWindow;
    public AccountDetailWindow accountDetailWindow;
    public PersonalDetailWindow personalDetailWindow;
    private HotelAdminWindowHandler hotelAdminWindowHandler = new HotelAdminWindowHandler(this);

    public HotelAdminWindow(String accountID){

        this.nowAccountID = accountID;

        roomDetailWindow = new RoomDetailWindow(nowAccountID);
        accountDetailWindow = new AccountDetailWindow(nowAccountID);
        personalDetailWindow = new PersonalDetailWindow(nowAccountID);

        hotelAdminPanel = new JPanel();
        this.add(hotelAdminPanel);
        hotelAdminPanel.setLayout(cardLayout);
        placeComponents(hotelAdminPanel);

        roomDetail.setActionCommand("roomDetail");
        roomDetail.addActionListener(hotelAdminWindowHandler);
        accountDetail.setActionCommand("accountDetail");
        accountDetail.addActionListener(hotelAdminWindowHandler);
        personalDetail.setActionCommand("personalDetail");
        personalDetail.addActionListener(hotelAdminWindowHandler);

        this.setBackground(Color.white);
        setTitle("酒店管理员界面");
        setBounds(0, 0, 800, 530);
        setLocationRelativeTo(null);//居中显示
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);  //用户单击窗口的关闭按钮时程序执行的操作
        setResizable(false);
        setVisible(true);

    }

    private void placeComponents(JPanel signPanel){
        menuBar.add(roomDetail);
        menuBar.add(accountDetail);
        menuBar.add(personalDetail);

        hotelAdminPanel.add(roomDetailWindow,"roomDetailPanel");
        hotelAdminPanel.add(accountDetailWindow,"accountDetailPanel");
        hotelAdminPanel.add(personalDetailWindow,"personalDetailPanel");

        this.setJMenuBar(menuBar);

    }

}
